package cn.itcast.search.mq;

import cn.itcast.search.servicer.Serviceiten;
import org.elasticsearch.action.index.IndexRequest;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ltemIistEner {

    @Autowired
    private Serviceiten serviceiitens;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("item_up_queue"),
            exchange = @Exchange(value = "hmall.topic", type = ExchangeTypes.TOPIC),
            key = "hmall.insert"

    ))
    public void additem(Long id) {
        serviceiitens.additem(id);
    }










    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("item_down_queue"),
            exchange = @Exchange(value = "hmall.topic", type = ExchangeTypes.TOPIC),
            key = "hmall.delete"

    ))
    public void deleteitem(Long id) {
        serviceiitens.deleteitem(id);

    }

}
